<script type="text/javascript">
  quickLocationVal();
  quickSearchVal();
  getLocationDropdownList();
</script>
<div class="col-sm-3 content-left">
  <h4>
    <span>Location</span>
    <?php if (!empty($this->signed_user)) { ?>
      <a class="pull-right" onclick="setLocation('<?php echo $this->signed_user['user_location_key']; ?>');" title="Reset">&nbsp;<i class="fa fa-refresh"></i></a>
    <?php } ?>
  </h4>
  <div class="well well-sm clearfix">
    <p class="text-center">
      <?php if (!empty($this->location_data)) { ?>
        <?php if ($this->location_data['level'] == 1) { ?>
          <a onclick="setLocation('<?php echo $this->location_data['country_id'] . '@1'; ?>');"><b><?php echo $this->location_data['country_name']; ?></b></a>
        <?php } ?>
        <?php if ($this->location_data['level'] == 2) { ?>
          <a onclick="setLocation('<?php echo $this->location_data['country_id'] . '@1'; ?>');"><?php echo $this->location_data['country_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['state_id'] . '@2'; ?>');"><b><?php echo $this->location_data['state_name']; ?></b></a>
        <?php } ?>
        <?php if ($this->location_data['level'] == 3) { ?>
          <a onclick="setLocation('<?php echo $this->location_data['country_id'] . '@1'; ?>');"><?php echo $this->location_data['country_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['state_id'] . '@2'; ?>');"><?php echo $this->location_data['state_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['district_id'] . '@3'; ?>');"><b><?php echo $this->location_data['district_name']; ?></b></a>
        <?php } ?>
        <?php if ($this->location_data['level'] == 4) { ?>
          <a onclick="setLocation('<?php echo $this->location_data['country_id'] . '@1'; ?>');"><?php echo $this->location_data['country_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['state_id'] . '@2'; ?>');"><?php echo $this->location_data['state_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['district_id'] . '@3'; ?>');"><?php echo $this->location_data['district_name']; ?></a>
          <span>&nbsp;>&nbsp;</span>
          <a onclick="setLocation('<?php echo $this->location_data['locality_id'] . '@4'; ?>');"><b><?php echo $this->location_data['locality_name']; ?></b></a>
        <?php } ?>
      <?php } else { ?>
        <span>Set your location</span>
      <?php } ?>
    </p>
    <form id="quick_loc_form" class="form" role="form" method="post" action="<?php echo site_url('location/search'); ?>">
      <div class="form-group">
        <input name="location_name" id="location_name" type="text" class="form-control" placeholder="Country, State or District" autocomplete="off"/>
        <button class="btn btn-default btn-block btn-sm btn-search" type="submit"><i class="fa fa-globe"></i>&nbsp;<span>Set</span></button>
      </div>
    </form>
  </div>
  <h4>
    <span>Search</span>
  </h4>
  <div class="well well-sm clearfix">
    <form id="quick_search_form" class="form" method="get" action="<?php echo site_url('search'); ?>">
      <div class="form-group">
        <input type="text" name="search_term" id="search_term" class="form-control" placeholder="iPhone 4S" required="true" maxlength="50"/>
        <small>
          <label>
            <input type="radio" name="search_type" id="search_type" checked="true" value="1"/>
            <span>Ads</span>
          </label>
          <label>
            <input type="radio" name="search_type" id="search_type" value="2"/>
            <span>Needs</span>
          </label>
        </small>
        <button class="btn btn-default btn-sm btn-search" type="submit"><i class="fa fa-search"></i>&nbsp;<span>Search</span></button>
      </div>
    </form>
  </div>
  <?php if (!empty($categories)) { ?>
    <h4>
      <span>Category</span>
      <a class="route-controller pull-right" href="<?php echo site_url('category'); ?>" title="More">&nbsp;<i class="fa fa-plus"></i></a>
    </h4>
    <div class="list-group categories">
      <?php foreach ($categories as $category) { ?>
        <?php $cat_icon = (!empty($category['category_icon'])) ? $category['category_icon'] : 'fa-certificate'; ?>
        <a class="list-group-item route-controller <?php if (!empty($menu_active) && $menu_active == 'category_' . $category['category_id']) { ?> active <?php } ?>" href="<?php echo site_url('category/' . $category['category_id'] . '/' . urlfy_text($category['category_name'])); ?>"><i class="fa <?php echo $cat_icon; ?>"></i>&nbsp;<?php echo $category['category_name']; ?></a>
      <?php } ?>
    </div>
  <?php } ?>
  <?php if (!empty($filter['filter_enabled'])) { ?>
    <?php $this->load->view('common/sidebar_filter'); ?>
  <?php } ?>
</div>